package com.pda.xinma.presenter;

import com.pda.xinma.bean.ExceptionsListBean;
import com.pda.xinma.contract.ExceptionalContract;
import com.pda.xinma.net.NetUtils;
import com.wangshen.base.net.bean.BaseRowsAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import java.util.List;

import io.reactivex.functions.Consumer;

public class ExceptionalPresenter extends BasePresenter<ExceptionalContract.View> implements ExceptionalContract.Presenter{
    @Override
    public void exceptionsList(String taskNo,int pager) {
        NetUtils.geApi().exceptionsList(taskNo,pager,10)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseRowsAppEntity<List<ExceptionsListBean>>>() {
                    @Override
                    public void accept(BaseRowsAppEntity<List<ExceptionsListBean>> listBaseRowsAppEntity) throws Exception {
                        getView().setList(listBaseRowsAppEntity.getRows());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
